/**
 * 您还可以使用CommonsChunkPlugin将脚本中的供应商库提取到单独的文件中。
 * 
 * 
 * */ 

var webpack = require('webpack');

module.exports = {
  entry: {
    app: './main.js',
    vendor: ['jquery'],  // ['jquery'] tells Webpack that jquery should be included in the common chunk vendor.js.
  },
  output: {
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      filename: 'vendor.js'
    })
  ]
};


/**
 * 自动加载jquery 不需要 导入
 * such as making $ and jQuery available in every module without writing require("jquery"). 
 * You should use ProvidePlugin (Official doc) which automatically loads modules 
 * instead of having to import or require them everywhere.
 * 
 * 
 * // main.js
$('h1').text('Hello World');


// webpack.config.js
var webpack = require('webpack');

module.exports = {
  entry: {
    app: './main.js'
  },
  output: {
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery'
    })
  ]
};
 * */ 